import java.util.Arrays;

/**
 * @USER: Administrator
 * @DATE: 2024/9/28 下午1:29
 * @VERSION: 1.0.0
 */
public class LC1608 {
    public static void main(String[] args) {
        LC1608 lc1608 = new LC1608();
        System.out.println(lc1608.specialArray(new int[]{3,5}));
    }

    public int specialArray(int[] nums) {
        Arrays.sort(nums);
        int result = -1;
        int n = nums.length;
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < nums.length; j++) {
                if (nums[j] >= i ) {
                    if (n-j==i) {
                        return i;
                    }else {
                        break;
                    }

                }
            }
        }
        return result;
    }

}
